---
redirect_from:
  - /frontend-introduction/vue
---

# Vue

Cube is visualization-agnostic, so you can build any user interface for your
application.

You can directly query Cube Backend using
JSON [Query Format](/product/apis-integrations/rest-api/query-format) via [HTTP API](/reference/rest-api)
or
[WebSockets](/product/apis-integrations/rest-api/real-time-data-fetch#web-sockets)
and visualize analytical data with tools of your choice. However, it's much
easier to use the Cube JavaScript client and bindings for popular frameworks
such as React, Angular, and Vue.

The client has methods to communicate with Cube API Gateway and retrieve and
process data. It is designed to work with existing charting libraries including
Chart.js, D3.js, and more.

## Cube JavaScript Client

The client provides methods to solve common tasks:

**Abstract from the transport and query data.** You can
[fetch data](/reference/frontend/cubejs-client-core#load) from Cube Backend or
subscribe to
[real-time updates](/product/apis-integrations/rest-api/real-time-data-fetch)
regardless of the protocol, be it HTTP or WebSockets.

**Transform data for visualization.** You can
[pivot](/reference/frontend/cubejs-client-core#pivot) the result set to display
as a [chart](/reference/frontend/cubejs-client-core#chart-pivot) or as a
[table](/reference/frontend/cubejs-client-core#table-pivot), split into
[series](/reference/frontend/cubejs-client-core#series) or
[table columns](/reference/frontend/cubejs-client-core#table-columns).

**Simplify work with complex query types.** You can build
[Drill Down](/reference/frontend/cubejs-client-core#drill-down) queries and
[decompose](/reference/frontend/cubejs-client-core#decompose) the results of
[compare date range queries][ref-compare-date-range]
or [Data Blending](/product/data-modeling/concepts/data-blending) queries.

[Learn more](/reference/frontend/cubejs-client-core) in the documentation for
the `@cubejs-client/core` package.

## Cube Vue Package

The package provides convenient tools to work with Cube in Vue:

**Components.** You can use
[QueryBuilder](/reference/frontend/cubejs-client-vue#query-builder) and
[QueryRenderer](/reference/frontend/cubejs-client-vue#query-renderer) components
to abstract state management and API calls from your rendering code.

## Example Usage

Here are the typical steps to query and visualize analytical data in Vue:

- **Import `@cubejs-client/core` and `@cubejs-client/vue` packages.** These
  packages provide all the necessary methods and convenient Vue tools.
- **Create an instance of Cube JavaScript Client.** The client is initialized
  with Cube API URL. In development mode, the default URL is
  [http://localhost:4000/cubejs-api/v1](http://localhost:4000/cubejs-api/v1).
  The client is also initialized with an [API token](/product/auth), but it
  takes effect only in [production](/product/deployment/production-checklist).
- **Query data from Cube Backend.** Use
  [QueryBuilder](/reference/frontend/cubejs-client-vue#query-builder) or
  [QueryRenderer](/reference/frontend/cubejs-client-vue#query-renderer) and
  their props to execute a query and transform the result set. See
  [Query Format](/product/apis-integrations/rest-api/query-format) for details.
- **Transform data for visualization.** Use
  [QueryBuilder](/reference/frontend/cubejs-client-vue#query-builder) and
  [QueryRenderer](/reference/frontend/cubejs-client-vue#query-renderer) slots
  props to transform the result set. Furthermore, the result set has convenient
  methods, such as `series` and `chartPivot`, to prepare data for charting.
- **Visualize the data.** Use tools of your choice to draw charts and create
  visualizations.

See an example of using Cube with Vue and Chart.js library. Note that you can
always use a different charting library that suits your needs:

<iframe
  src="https://codesandbox.io/embed/cubejs-vue-demo-trww8?fontsize=14&hidenavigation=1&theme=dark"
  style={{
    width: "100%",
    height: 500,
    border: 0,
    borderRadius: 4,
    overflow: "hidden",
  }}
  sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
></iframe>

## Getting Started

You can install Cube JavaScript Client and the Vue package with npm or Yarn:

```bash{outputLines: 1,3-4}
# npm
npm install --save @cubejs-client/core @cubejs-client/vue3

# Yarn
yarn add @cubejs-client/core @cubejs-client/vue3
```

**Note.** If you're using Vue 2, please use `@cubejs-client/vue`.

Now you can build your application from scratch or connect to one of our
[supported data visualization tools](/product/configuration/visualization-tools).
You can also [explore example applications](https://cube.dev/examples) built with Cube.


[ref-compare-date-range]: /product/apis-integrations/queries#compare-date-range-query